from django.db import models


# IP地址测试地段
class ShowAddress(models.Model):
    id = models.AutoField(primary_key=True,auto_created=True)
    protocol = models.CharField("协议类型",max_length=20,blank=True)
    address = models.CharField("IP地址", max_length=20,blank=True)
    min = models.CharField("延迟时间", max_length=20,blank=True)
    ip_mac = models.CharField("MAC地址", max_length=20,blank=True)
    ip_type = models.CharField("类型", max_length=20,blank=True)
    interface = models.CharField("接口地址", max_length=20,blank=True)
    time = models.DateTimeField("记录日期",auto_now_add=True)

    class Meta:
        verbose_name = '交换机信息'
        verbose_name_plural = '交换机接口信息'

    def __str__(self):
        return self.id

# 资产自动在线测试
class TestComputer(models.Model):
    id = models.AutoField(primary_key=True)
    it_number = models.CharField("资产编号", max_length=100, blank=True)  # IT资产编号
    seat_number = models.CharField("座位编号", max_length=100)            # 座位编号
    asset_users = models.CharField("资产使用者", max_length=20)           # 资产使用者
    mac_network = models.CharField("MAC地址",max_length=100)              # 网卡MAC地址
    c_network = models.CharField("IP地址",max_length=40)                 # IP 地址
    auto_test = models.CharField("是否自动提交",max_length=10)
    c_time = models.DateTimeField("更新时间", auto_now_add=True)              # 更新时间


    class Meta:
        verbose_name = '资产自动在线测试'
        verbose_name_plural = '资产自动在线测试'

    def __str__(self):
        return self.id


# 防火墙日志类型
class NetworkLog(models.Model):
    id = models.AutoField(primary_key=True)
    time = models.CharField("日志时间", max_length=50)            # 日志时间
    deviceip=models.CharField("设备IP", max_length=20)           # 设备IP
    srcip = models.CharField("内网IP", max_length=50)            # 内网IP
    username = models.CharField("用户名", max_length=20)         # 用户名
    site = models.CharField("网站", max_length=100)             # 网站
    url = models.CharField("网址", max_length=200)              # 网址
    mac = models.CharField("MAC地址", max_length=20)            # MAC地址
    seat_number = models.CharField("具体位置",max_length=50)     # 具体位置
    asset_users = models.CharField("使用者",max_length=50)      # 使用者
    it_number = models.CharField('资产编号',max_length=50)      # 资产编号
    complete = models.CharField("完整参数", max_length=500)      # 完整的日志
    url_keyword = models.CharField("URL参考链接",max_length=100)#URL 参考链接


    class Meta:
        verbose_name = '防火墙日志'
        verbose_name_plural = '防火墙日志'

    def __str__(self):
        return self.id

# 防火墙匹配规则
class UrlKeyword(models.Model):
    id = models.AutoField(primary_key=True)
    url = models.CharField("网址", max_length=200)
    Keyword = models.CharField("网址解析", max_length=200)

    class Meta:
        verbose_name = 'URL网址解析'
        verbose_name_plural = 'URL网址解析'

    def __str__(self):
        return self.id